package com.htrq.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.htrq.dao.ICardDao;
import com.htrq.entity.ICBasInfo;
import com.htrq.entity.Page;

@Service
@Transactional(value="txManager2")
public class ICardService {
	@Resource
	private ICardDao icDao;
	
	public List<ICBasInfo> getAllCard(ICBasInfo info, Page page) throws ParseException {
		List<Object[]> list=icDao.findAll(info,page);
		List<ICBasInfo> ics= new ArrayList<ICBasInfo>();
		for(Object[] obj :list){
			ICBasInfo ic=new ICBasInfo();
			ic.setAutoId(obj[0].toString());
			ic.setCardNumber(obj[1].toString());
			ic.setCardType(obj[2].toString());
			ic.setStatus(obj[3].toString());
			ic.setCreatDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(obj[4].toString()));//制卡时间
			ic.setCname(obj[5].toString());
			ic.setIDcard(obj[6].toString());
			ic.setTel(obj[7].toString());
			ic.setAddress(obj[8].toString());
			ic.setVehicleId(obj[9].toString());
			ic.setDriverLicense(obj[10].toString());
			ic.setVehicleType(obj[11].toString());//车辆类型
			ic.setQpnumber(obj[12].toString());
			//ic.setLascheckDate(obj[13]);//安检到期时间
			ic.setCompany(obj[14].toString());
			ic.setDeptId(obj[15].toString());
			ic.setGname(obj[16].toString());
			//ic.setLasmodifydate(obj[17]);//最后一次修改时间
			ics.add(ic);
		}
		return ics;
	}

	public Long getTotal(ICBasInfo info) {
		return icDao.getAll(info);
	}

	public List<Object[]> exportbyForm(ICBasInfo info) {
		//TODO Auto-generated method stub
		return icDao.findAll(info);
	}
}
